import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.figure import Figure

def grade_fig(grade_info: dict) -> Figure:
    grade_fig, ax = plt.subplots(1, 1, figsize=(12, 4))
    sns.barplot(
        x=grade_info['mes_sub_name'], 
        y=grade_info['mes_Score'], 
        hue = grade_info['mes_sub_name'],
        ax=ax, 
        palette=sns.color_palette("Set2", n_colors=len(grade_info['mes_sub_name'].unique())),
        legend= False
        )
    ax.set_title("各科平均得分")
    ax.set_xlabel("科目")
    ax.set_ylabel("得分")
    return grade_fig